home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / User's Guide / 06 Working with Files < prev    next >
Text File  |  1994-09-20  |  13KB  |  274 lines

  1. 6  Working with Files
  2.        This  section  describes the MacDOS commands which  let  you
  3.        work with files.
  4.  
  5.        Many  MacDOS commands operate on files. To tell MacDOS where
  6.        to  look  for  them, you specify the folder  which  contains
  7.        them.  If  you do not specify any folder, MacDOS  looks  for
  8.        the files in the current folder.
  9.  
  10. Identifying a File
  11.        Like with folders, you identify a file through its name  and
  12.        its  location.  Therefore,  to  identify  a  file  you  must
  13.        provide:
  14.          •   The ID of the volume which contains the file.
  15.          •    The  name of all folders, one inside the other, which
  16.           you  need  to open in order to "reach" from the root  the
  17.           file you are looking for.
  18.          •   The name of the file.
  19.  
  20.        To  fully  identify  a  file in  MacDOS  you  need  to  type
  21.        something like this:
  22.           1:\fold1\aDeeperFold\still deeper\myFile
  23.        and  all  the  considerations made in the  previous  section
  24.        concerning folders apply to files.
  25.  
  26.        File  names  are strings of up to 31 characters  in  length.
  27.        They  are not allowed to contain colons, and you should also
  28.        avoid  other special characters, as they can create problems
  29.        and  confusion. For example, if you include  a  slash  in  a
  30.        filename  and then forget to double quote the name when  you
  31.        use  it  in  a  command,  MacDOS  will  interpret  the  part
  32.        beginning with the slash as a switch. Moreover, most  MacDOS
  33.        commands  reject  as  bad switches names  beginning  with  a
  34.        slash,  whether  you double quote them or not.  For  similar
  35.        reasons,  you should also avoid backslashes. Also note  that
  36.        if  you  include  a  comma  in a  filename,  you  will  have
  37.        problems  in  copying it, because the command  COPY  accepts
  38.        comma-separated  filenames.  In  general,   try   to   avoid
  39.        characters which are used as separators.
  40.  
  41. Creating New Files
  42.        There are three ways of creating a new file with MacDOS:
  43.          •    Create  a  file with the command OPEN and then  write
  44.           into  it  lines  of text with the command  WRITE  (please
  45.           refer to one of the following sections for the details).
  46.          •    Use  the  command  LOG  to record  all  the  commands
  47.           executed  by  MacDOS (please refer to the "Getting  Info"
  48.           section of this User's Guide).
  49.          •    Redirect  the output of a MacDOS command  to  a  disk
  50.           file  (please refer to "The Environment" section of  this
  51.           User's Guide).
  52.  
  53.        By  default,  the  files  created are  of  type  'TEXT'  and
  54.        creator  'ttxt'  (ie. TeachText), but  you  can  change  the
  55.        creator by updating the system variable CREATOR.
  56.  
  57. Removing Files
  58.        You  can  remove files with the commands DEL and ERASE.  The
  59.        two  commands  have  different names but are  identical  for
  60.        what  concerns functionality. Therefore, what is said  about
  61.        DEL always applies 100% to ERASE.
  62.  
  63.        DEL  accepts a single parameter which specifies the file you
  64.        want to delete or the folder you want to empty of files.  If
  65.        you  include  wildcard  characters  in  the  parameter,  DEL
  66.        deletes  all the files whose names match the parameter.  You
  67.        also  have  the possibility of selecting files on the  basis
  68.        of their creator, type, or both.
  69.  
  70.        To  delete  all  the files in a particular folder,  you  can
  71.        pass  to  DEL a "catch all" filename or simply the  name  of
  72.        the folder:
  73.           del D:\theFolder\*
  74.           del D:\theFolder
  75.        In either case, MacDOS prompts you for confirmation.
  76.  
  77.        Note  that DEL permanently removes the files from the system
  78.        rather  than simply moving them to the Trash. To  limit  the
  79.        danger  of such a drastic behaviour, MacDOS prompts you  for
  80.        confirmation   before   deleting   each   individual   file.
  81.        Nevertheless,   you  can  switch  this  safeguard   off   by
  82.        executing  the  command   CONFIRM OFF  .  To  re-enable  the
  83.        prompting  for a single DEL command, add the switch  /P.  To
  84.        re-enable it permanently, execute the command  CONFIRM ON .
  85.  
  86. Listing Files
  87.        You can list files with two commands: MORE and TYPE.
  88.  
  89.        MORE  displays the content of the data fork of files of type
  90.        'TEXT'  one  page at a time. At the end of each  page,  MORE
  91.        waits  for you to type any character before continuing.  You
  92.        can also interrupt the listing by pressing cmd-dot (or cntl-
  93.        C).  MORE is a special command, in that it expects that  you
  94.        specify  a  file  as  input redirection  rather  than  as  a
  95.        parameter.   So,   if   you   want   to   list   the    file
  96.        2:\aFold\theFile, you must type:
  97.           more <2:\aFold\theFile
  98.        rather than simply:
  99.           more 2:\aFold\theFile
  100.  
  101.        TYPE, when used in its basic form, also lists the data  fork
  102.        of   files  of  type  'TEXT'  on  the  monitor  screen.  The
  103.        differences are that TYPE expects a file specification as  a
  104.        parameter  and only stops when it reaches the  End  Of  File
  105.        (EOF).  You  can pause and resume long listings with  cntl-S
  106.        and cntl-Q respectively.
  107.  
  108.        To  list  the  data or resource fork of any file  (not  only
  109.        text   files),  use  TYPE  with  the  switches  /H  and   /R
  110.        respectively. TYPE then lists the requested fork in HEX,  as
  111.        well as in ASCII, 16 bytes per line.
  112.  
  113. Copying Files
  114.        To  copy  files,  you can use the commands COPY  and  XCOPY.
  115.        This  section  only  describes COPY.  Please  refer  to  the
  116.        section "Working with Folders" for a description of XCOPY.
  117.  
  118.        In  its  simplest  form, COPY makes a duplicate  of  a  file
  119.        which  already  exists and places it in the current  folder:
  120.        copy  aFileSpec  . The difference with the "Duplicate"  menu
  121.        item  provided  by the Finder is that COPY's  duplicate  has
  122.        the  same name as the original file. Therefore, if you  COPY
  123.        a  file which already is in the current folder, your command
  124.        does  not  have any visible effect and you do  not  get  any
  125.        duplicate at all.
  126.  
  127.        If you pass to COPY a second file specification, you can:
  128.          •   specify a different name for the duplicate;
  129.          •    place  the  duplicate anywhere in the  system  rather
  130.           than in the current folder.
  131.        The  two file specifications are usually called "source" and
  132.        "destination".  With  this format,  you  can  reproduce  the
  133.        Finder's Duplicate function as follows:
  134.           copy fileName "fileName copy"
  135.        A  duplicate of the file fileName in the current folder (ie.
  136.        the  front window) is created and named fileName copy.  Note
  137.        that  the double quotes are only necessary because  the  new
  138.        name contains a space.
  139.  
  140.        If  you use the destination to specify a folder rather  than
  141.        a  file, the duplicate file is created with the same name as
  142.        the  original.  In  other words, the two following  commands
  143.        are equivalent:
  144.           copy fileName destFolder\fileName
  145.           copy fileName destFolder
  146.  
  147.        Still  using  the second parameter to specify a folder,  you
  148.        have three ways of COPYing several files at a time:
  149.  
  150.          •    By  replacing the single source with a series of file
  151.           specifications  separated by commata, you  COPY  all  the
  152.           individual  source  files  to  the  destination   folder:
  153.           copy file1,aFold\file2,2:file3 destFolder
  154.  
  155.          •    By  wildcarding the source, you COPY  all  the  files
  156.           with matching filenames to the destination folder:
  157.                copy sourceFolder\p*a??? destFolder
  158.  
  159.          •    By  using  the  first parameter to specify  a  folder
  160.           rather  than a file, you COPY all the files in the source
  161.           folder to the destination folder:
  162.                copy sourceFolder destFolder
  163.  
  164.        If  you specify more than one file as a source parameter but
  165.        use  the  second  parameter to specify a single  file,  COPY
  166.        merges all the sources to produce the destination. This  can
  167.        be  useful  to  append to each other several  data  or  text
  168.        files.
  169.  
  170.        COPY supports several options:
  171.        •  Append the source to an existing destination.
  172.        •  Only copy files of a given Creator or Type.
  173.        •  Only copy the Data or Resource fork of files.
  174.        •  Display a Prompt before overwriting destination files.
  175.        •  Only  copy  files  which  either  do  not  exist  in  the
  176.           destination  folder or do exist but have an older  Update
  177.           date and time.
  178.        •  Verify that the copies are correct.
  179.  
  180. Renaming Files
  181.        To  rename  files, you can use the commands REN and  RENAME.
  182.        Apart from their name, the two commands are identical.
  183.  
  184.        In its simplest format, REN works as follows:
  185.           ren fileSpec newName
  186.        The  first  parameter specifies the file to be  renamed  and
  187.        the  second parameter tells MacDOS what the new name  should
  188.        be.
  189.  
  190.        If  the first parameter ends with a wildcarded filename, all
  191.        the  files  with matching names are renamed. In  that  case,
  192.        the  second  parameter is used to replace in each  name  the
  193.        part  which  precedes  the  first  wildcard  character.  For
  194.        example:
  195.           ren abc* xyz
  196.        renames  abc  to  xyz,  abcf  to  xyzf,  "abc  whatever"  to
  197.        "xyz  whatever", etc. In this form, REN can also be used  to
  198.        insert a string before all filenames:
  199.           ren * prependThis
  200.  
  201.        MacDOS  also  accepts wildcards in the second parameter.  In
  202.        that  case,  MacDOS  matches the  groups  of  wildcards  and
  203.        replaces the corresponding parts.
  204.  
  205.        If  the  first  parameter specifies a folder rather  than  a
  206.        file,   MacDOS  renames  all  the  files  in   the   folder.
  207.        Therefore,   the  two  following  commands  have   identical
  208.        results:
  209.           ren aFold\* x*z
  210.           ren aFold x*z
  211.        In  both cases, MacDOS prepends an 'x' and appends a 'z'  to
  212.        the name of each file in the folder aFold.
  213.  
  214.        Through a series of options, REN also lets you select  files
  215.        on  the  basis  of  their creator and  type.  You  can  also
  216.        specify  whether the name selection should be case sensitive
  217.        or not.
  218.  
  219. Changing File Attributes
  220.        You   can  use  the  command  REN  and  (RENAME,  which   is
  221.        identical) to change more than just the names of  files.  In
  222.        particular, you can:
  223.          •   set new creators;
  224.          •   set new file-types;
  225.          •    set  the  date  and time of the last  update  to  the
  226.           current date and time;
  227.          •   hide a visible file and viceversa.
  228.  
  229.        This  functionality  is  controlled  through  switches.  For
  230.        example,  "ren  zz  /h"  hides  the  file  named   zz,   and
  231.        "ren/c!????"  changes  the  creator  of  all  files  in  the
  232.        current folder to '????' (be careful!).
  233.  
  234. Printing Text Files
  235.        You  can print files of type 'TEXT' with the command  PRINT.
  236.        The format of PRINT is:  print fileSpec .
  237.  
  238.        The  file specification can be wildcarded or can be replaced
  239.        with  a  folder specification, in which case all text  files
  240.        in  the  folder are printed. Without parameter, PRINT prints
  241.        what is displayed in the console window.
  242.  
  243.        Before  PRINTing, you can specify the page format  with  the
  244.        standard "Page Setup ..." item of the File menu.
  245.  
  246.        Instead  of displaying the standard Print dialog every  time
  247.        you  print, MacDOS prints with a default selection, so  that
  248.        you  can  PRINT several files without having  to  click  for
  249.        each  one of them. With the /D switch you can direct  MacDOS
  250.        to  display  the standard "Print..." dialog before  printing
  251.        the first file.
  252.  
  253. Direct File I/O
  254.        MacDOS  lets  you OPEN, READ or WRITE, and  CLOSE  files  of
  255.        type 'TEXT'.
  256.  
  257.        You  can OPEN a file for reading, writing, or appending.  In
  258.        each  case,  one  line of text at a time is  transferred  in
  259.        each  I/O  operation, either from disk  to  memory  or  from
  260.        memory to disk. When READing, you can store the line into  a
  261.        global  variable  for later processing, or  display  it  for
  262.        immediate view.
  263.  
  264.        After  you  have  READ  from a file the  last  line,  MacDOS
  265.        automatically closes it.
  266.  
  267.        By  default,  MacDOS creates new files with  creator  'ttxt'
  268.        (ie.  TeachText),  but  you can change  it  by  setting  the
  269.        system variable CREATOR to your preferred creator.
  270.  
  271.        Type  OPEN without parameters to display the list  of  files
  272.        which are currently open.
  273.  
  274.